package com.huidao.servlet.Goods;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.huidao.entity.Goods;
import com.huidao.entity.GoodsType;
import com.huidao.service.GoodsService;
import com.huidao.service.GoodsServiceImp;


public class UpdateGoodsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UpdateGoodsServlet() {
    }


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Goods goods = new Goods();
		goods.setGid(Long.parseLong(request.getParameter("id")));
		goods.setgName(request.getParameter("gname"));
		goods.setgAccount(Integer.parseInt(request.getParameter("gaccount")));
		goods.setgPrice(Double.parseDouble(request.getParameter("gprice")));
		GoodsType gt = new GoodsType();
		gt.setGoodstype_id(Long.parseLong(request.getParameter("gstype")));
		goods.setGoodsType(gt);
		GoodsService gs = new GoodsServiceImp();
		String data = gs.updateGoods(goods);
		if(data.equals("")){
			request.getRequestDispatcher("sellergoodslist.jsp").forward(request, response);
		}else{
			response.getWriter().print(data);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
